<?php
namespace app\index\model;
use think\Model;
use app\index\model\Cate;
class Article extends Model
{
    public function getAllart($cateid){
    	$cate=new Cate();
    	$allCateid=$cate->getchildren($cateid);
    	//dump($allCateid);die;
    	$artRes=db('article')->where("cateid IN($allCateid)")->paginate(6);
    	return $artRes;
    }

   public function gethotart($cateid){
    	$cate=new Cate();
    	$allCateid=$cate->getchildren($cateid);
    	//dump($allCateid);die;
    	$artRes=db('article')->where("cateid IN($allCateid)")->order('click desc')->limit(6)->paginate(3);
    	return $artRes;
    }
    //获取最新的文章
    public function getnewArt(){
       $newArt=db('article')->field('a.id,a.title,a.desc,a.thumb,a.click,a.zan,a.time,c.catename')->alias('a')->join('bk_cate c','a.cateid=c.id')->limit(10)->order('a.id desc')->select();
       return $newArt;
    }
    
    public function getSerHot(){
       $artRes=db('article')->order('click desc')->limit(5)->select();
        return $artRes; 
    }

    //获取热点文章
    public function getsitehot(){
       $sitehot=$this->field('id,title,thumb')->order('click desc')->limit(5)->select();
       return $sitehot;
    }

    //获得推荐栏目
    public function getRecart(){
      $recart=$this->field('id,title,thumb')->where('rec',1)->order('id desc')->limit(4)->select();
      return $recart;
    }
}
